import python_baway.exercise.mysql.oop.MysqlHelper as MysqlHelper
from python_baway.common.xdb import xdb_args

xhelper = MysqlHelper.MysqlHelper(**xdb_args)

xtable_name = 'classes_ppt15_page11'

xsqls = (
    f'DROP TABLE IF EXISTS {xtable_name}',
    f'''CREATE TABLE IF NOT EXISTS {xtable_name}
(
	id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
	name varchar(20) NULL DEFAULT NULL
)
CHARACTER SET = utf8
COLLATE = utf8_general_ci''',
    f"ALTER TABLE {xtable_name} ADD courses varchar(20) NULL DEFAULT NULL comment '课程'",
    f"ALTER TABLE {xtable_name} CHANGE courses course varchar(20) NULL DEFAULT NULL comment '课程'",
    f"ALTER TABLE {xtable_name} DROP course",
    f"ALTER TABLE {xtable_name} ADD courses varchar(20) NULL DEFAULT NULL comment '课程'",
)

for xsql in xsqls:
    xr = xhelper.exec(xsql)
    print(f'Affected rows: {xr}')

xhelper.close()
